﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using CrazyWorship1.Creators;
using System.Windows.Media.Media3D;
using System.Windows.Media.Animation;

namespace CrazyWorship1.Controllers
{
    public class ControllerBase
    {
        public CreateAllBase ParentCreator
        {
            get
            {
                return parentCreator;
            }
            set
            {
                parentCreator = value;
            }
        }
            private CreateAllBase parentCreator;
       protected Model3DGroup TextModelGroup
        {
            get
            {
                return parentCreator.TextModelGroup;
            }
        }
       protected State CurrentState
       {
           get
           {
               return parentCreator.CurrentState;
           }
       }
        protected Model3DGroup BackgroundModelGroup
        {
            get
            {
                return parentCreator.BackgroundModelGroup;
            }
        }
        public void SetProperty(string name, string value)
        {
            Type t = this.GetType();
            PropertyInfo[] p = t.GetProperties();
            //  ArrayList properties = new ArrayList();

            foreach (PropertyInfo pi in p)
            {
                if (pi.IsDefined(typeof(DataAttribute), true) && pi.CanWrite)
                {
                    object[] fields = pi.GetCustomAttributes(typeof(DataAttribute), true);
                    foreach (DataAttribute d in fields)
                    {
                        if (d.FieldName == name)
                        {
                            pi.SetValue(this, value, null);
                        }
                    }

                }
            }

        }
        public virtual void Go()
        {
         

        }
    }
}
